package com.bdqn.spark.chapter05.kv

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

object Spark24_RDD_Operator_Transform {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf()
      .setMaster("local[*]")
      .setAppName("operator-join")
    val sc = new SparkContext(sparkConf)

    // 算子 - (Key - Value类型)
    val rdd1 = sc.makeRDD(List(
      ("a", 1), ("a", 2), ("c", 3),("d", 3)
    ))

    val rdd2 = sc.makeRDD(List(
      ("a", 5), ("c", 6),("a", 4)
    ))

    val value: RDD[(String, (Int, Int))] = rdd1.join(rdd2)
    value.collect().foreach(println)

    sc.stop()


  }
}
